package com.hncc.sms.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.hncc.sms.domain.SysRoleManager;
import com.hncc.sms.service.ISysRoleManagerService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import javax.annotation.Resource;

/**
 * 角色信息Controller
 * 
 * @author ruoyi
 * @date 2020-08-11
 */
@RestController
@RequestMapping("/sms/role")
@Api(tags = "角色信息接口")
public class SysRoleManagerController extends BaseController
{
    @Resource
    private ISysRoleManagerService sysRoleManagerService;

    /**
     * 查询角色信息列表
     */
    @ApiOperation(value = "条件分页查询角色信息",httpMethod = "GET")
    @PreAuthorize("@ss.hasPermi('sms:role:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysRoleManager sysRoleManager)
    {
        startPage();
        List<SysRoleManager> list = sysRoleManagerService.selectSysRoleManagerList(sysRoleManager);
        return getDataTable(list);
    }

    /**
     * 导出角色信息列表
     */
    @PreAuthorize("@ss.hasPermi('sms:role:export')")
    @Log(title = "角色信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SysRoleManager sysRoleManager)
    {
        List<SysRoleManager> list = sysRoleManagerService.selectSysRoleManagerList(sysRoleManager);
        ExcelUtil<SysRoleManager> util = new ExcelUtil<SysRoleManager>(SysRoleManager.class);
        return util.exportExcel(list, "role");
    }

    /**
     * 获取角色信息详细信息
     */
    @ApiOperation(value = "根据roleId获取角色信息详细信息",httpMethod = "GET",
            notes = "根据roleId查询角色信息")
    @ApiImplicitParam(paramType = "path",name = "roleId",value = "角色信息id",dataType = "Long",required = true)
    @PreAuthorize("@ss.hasPermi('sms:role:query')")
    @GetMapping(value = "/{roleId}")
    public AjaxResult getInfo(@PathVariable("roleId") Long roleId)
    {
        return AjaxResult.success(sysRoleManagerService.selectSysRoleManagerById(roleId));
    }

    /**
     * 新增角色信息
     */
    @ApiOperation(value = "新增",httpMethod = "POST", notes = "新增角色信息")
    @ApiImplicitParam(name = "sysRoleManager", value = "新增角色信息", dataType = "SysRoleManager")
    @PreAuthorize("@ss.hasPermi('sms:role:add')")
    @Log(title = "角色信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysRoleManager sysRoleManager)
    {
        return toAjax(sysRoleManagerService.insertSysRoleManager(sysRoleManager));
    }

    /**
     * 修改角色信息
     */
    @ApiOperation(value = "修改", httpMethod = "PUT", notes = "修改角色信息")
    @ApiImplicitParam(name = "sysRoleManager", value = "修改角色信息", dataType = "SysRoleManager")
    @PreAuthorize("@ss.hasPermi('sms:role:edit')")
    @Log(title = "角色信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysRoleManager sysRoleManager)
    {
        return toAjax(sysRoleManagerService.updateSysRoleManager(sysRoleManager));
    }

    /**
     * 删除角色信息
     */
    @ApiOperation(value = "批量删除", httpMethod = "DELETE", notes = "根据roleIds删除角色信息")
    @ApiImplicitParam(paramType = "path",name = "roleIds",value = "角色信息id",dataType = "Long[]",required = true)
    @PreAuthorize("@ss.hasPermi('sms:role:remove')")
    @Log(title = "角色信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{roleIds}")
    public AjaxResult remove(@PathVariable Long[] roleIds)
    {
        return toAjax(sysRoleManagerService.deleteSysRoleManagerByIds(roleIds));
    }

}
